<template>
  <div class="search-bottom">
    <h3>热门搜索</h3>
    <ul>
      <li 
        v-for="(item, index) in hotBot" 
        :key="index"
        :item="item"
        @click.stop="$emit('newValue',item.first)"
        >{{ item.first }}</li>
    </ul>
    <!-- 历史搜索 -->
    <ol class="history">
      <li v-for="(item, index) in searchArr" :key="index">
        <i class="iconfont icon-shijian"></i>
        <div class="text">
          <span @click.stop="$emit('newValue',item)">{{ item }}</span>
          <i
            class="iconfont icon-shanchu2"
            @click.stop="$emit('remove', item)"
          ></i>
        </div>
      </li>
    </ol>
  </div>
</template>

<script>
export default {
  props: {
    searchArr: Array,
  },
  data() {
    return {
      hotBot: {},
    };
  },
  created: function () {
    // 热门搜索
    this.axios.get("https://apis.netstart.cn/music/search/hot").then((res) => {
      this.hotBot = res.data.result.hots;
    });
  },
};
</script>

<style lang="less">
.search-bottom {
  padding: 15px 10px 0;
  h3 {
    font-size: 12px;
    color: #666;
  }
  ul {
    margin: 10px 0 7px;
    li {
      height: 32px;
      line-height: 32px;
      border-radius: 16px;
      border: 1px solid rgba(0, 0, 0, 0.1);
      padding: 0px 14px;
      margin: 0 8px 8px 0;
      display: inline-block;
      font-size: 14px;
      color: #333;
    }
  }
  .history {
    li {
      display: flex;
      height: 45px;
      align-items: center;
      i {
        margin: 0 10px;
        font-size: 20px;
        color: #c9caca;
      }
      .text {
        flex: 1;
        display: flex;
        align-items: center;
        height: 100%;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        span {
          flex: 1;
          font-size: 14px;
          color: #333;
        }
        i {
          font-size: 16px;
        }
      }
    }
  }
}
</style>